# To change this template, choose Tools | Templates
# and open the template in the editor.
#
# todo
#   +function to create sudokus

__author__="martin"
__date__ ="$04.04.2010 12:38:24"

import sudoku
import scipy
import sys

def transfer_sudoku(filename):
    f1=open(filename)
    s_array=scipy.zeros([sudoku.size, sudoku.size])
    i=0
    for data in f1:
        data2=data.rstrip()
        i+=1
        
        x=0
        y=0
        for n in data2:
            #print n
            if n!=".":
                #print n
                s_array[x,y]=n
            else:
                s_array[x,y]=0
            if x < sudoku.size-1:
                x+=1
            else:
                x=0
                if y < sudoku.size-1:
                    y+=1
                else:
                    y=0
                    ofname=filename[0:filename.index(".")]+"_"+str(i)+".txt"
                    sudoku.save_sudoku(ofname, s_array)
 
    f1.close() 
                
if __name__=="__main__":
    transfer_sudoku(sys.argv[1])
        